﻿/// <reference path="turbo_common.js" />
/// <reference path="../General/Events/EventSender.js" />

var _____a;


var HttpVerb = { Get: 0, Post: 1 };
var PostMode = { Ajax: 0, Page: 1 };


var $PostControl = TA.Turbo.Common.PostControl = function PostControl()
{
}
$PostControl.Inherit(BaseJsonDeserializable);

// PROPS
$PostControl.prototype.ControlId = "";
$PostControl.prototype.Value = true;
$PostControl.prototype.Properties = new Array();
$PostControl.prototype.SendAs = "";
$PostControl.prototype._control = null;

$PostControl.prototype.DeserializeContent = function DeserializeContent(prShortName, value)
{
	switch (prShortName)
	{
		case "I": this.ControlId = value; break;
		case "V": this.Value = value; break;
		case "P": this.Properties = value; break;
		case "S": this.SendAs = value; break;
	}
}
$PostControl.prototype.get_Control = function get_Control()
{
	return document.getElementById(this.ControlId);
}

var $PostScenario = TA.Turbo.Common.PostScenario = function PostScenario()
{
	this.EventSender();

	this.PostUrl = theForm.action;
}
$PostScenario.Inherit(EventSender);
$PostScenario.Inherit(BaseJsonDeserializable);

if (_____a)
{
	$PostScenario.prototype = new EventSender();
}

// PROPS
$PostScenario.prototype.Id = "";
$PostScenario.prototype.HttpVerb = HttpVerb.Post;
$PostScenario.prototype.PostMode = PostMode.Ajax;
$PostScenario.prototype.PostUrl = "";
$PostScenario.prototype.ValidationGroupList = new Array();
$PostScenario.prototype.SendHashString = false;
$PostScenario.prototype.CausesValidation = true;
$PostScenario.prototype.Clean = false;

//LISTS
$PostScenario.prototype.PostControls = new Array();
$PostScenario.prototype.ProgressControls = new Array();
// EVENTS
$PostScenario.prototype.Posting = "";
$PostScenario.prototype.Posted = "";
$PostScenario.prototype.Response = "";
$PostScenario.prototype.ResponseProcessed = "";
$PostScenario.prototype.Error = "";

$PostScenario.prototype.DeserializeContent = function DeserializeContent(prShortName, value)
{
	switch (prShortName)
	{
		case "I": this.Id = value; break;
		case "P": this.PostUrl = value; break;
		case "V": this.HttpVerb = value; break;
		case "M": this.PostMode = value; break;
		case "H": this.SendHashString = value; break;
		case "C": this.CausesValidation = value; break;
		case "L": this.Clean = value; break;
		case "Pi":
			this.AddEvent("Posting", value);
			break;
		case "Pe":
			this.AddEvent("Posted", value);
			break;
		case "R":
			this.AddEvent("Response", value);
			break;
		case "D": 
			this.AddEvent("ResponseProcessed", value);
			break;
		case "O": 
			this.AddEvent("Error", value);
			break;
		case "G": this.ValidationGroupList = value; break;
		case "W":
			this.PostControls = new Array();
			for (var i = 0; i < value.length; ++i)
			{
				var t = new $PostControl();
				t.Deserialize(value[i]);
				this.PostControls.push(t);
			}
			break;
		case "T":
			this.ProgressControls = new Array();
			for (var i = 0; i < value.length; ++i)
			{
				this.ProgressControls.push(document.getElementById(value[i]).get_Object());
			}
			break;
	}
}


TA.Turbo.Common._EnsureScenario = function _EnsureScenario(postScenarioId)
{
	if (!(TA.Turbo.Common.PostScenarios[postScenarioId] instanceof $PostScenario))
	{
		var psAjax = TA.Turbo.Common.PostScenarios[postScenarioId];
		TA.Turbo.Common.PostScenarios[postScenarioId] = new $PostScenario();
		TA.Turbo.Common.PostScenarios[postScenarioId].Deserialize(psAjax);
	}
}
